<!DOCTYPE html>
<html lang="en">
<head>
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,initial-scale=1.0,user-scalable=no">
    <meta charset="UTF-8">
    <title>mobile-drag</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        #box{
            width: 100px;
            height: 100px;
            background: blue;
            position: relative;
            left: 0;
            top: 0;
        }
    </style>
</head>
<body>
<div id="box"></div>
<script>
    var box=document.querySelector("#box");
    var isDrag=false;
    var disx,disy;
    box.addEventListener("touchstart",touchStart);
    box.addEventListener("touchmove",touchMove);
    box.addEventListener("touchend",touchEnd);
    function touchStart(e) {
        isDrag=true;
        disx=e.touches[0].clientX-this.offsetLeft;
        disy=e.touches[0].clientY-this.offsetTop;
    }
    function touchMove(e){
            if(isDrag){
                this.style.left=(e.touches[0].clientX-disx)+"px";
                this.style.top=(e.touches[0].clientY-disy)+"px";
            }
    }
    function touchEnd(e) {
        isDrag=false;
    }
    document.addEventListener("touchstart",function (e) {
        e.preventDefault();
    })
</script>
</body>
</html>